package com.trust.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.trust.agri.util.BeanUtil;
import com.trust.entity.Storehouse;
import com.trust.entity.result.DropDownResult;
import com.trust.mapper.StorehouseMapper;
import com.trust.service.StorehouseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class StorehouseServiceImpl extends ServiceImpl<StorehouseMapper, Storehouse> implements StorehouseService {

    @Override
    public List<DropDownResult> dropDownList() {
        LambdaQueryWrapper<Storehouse> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Storehouse::getEnabled ,1);
        wrapper.orderByDesc(Storehouse::getId);
        List<Storehouse> list = this.list(wrapper);
        List<DropDownResult> targetList = BeanUtil.sourceList2targetList(list, DropDownResult.class);
        return targetList;
    }
}
